

//1、创建按钮矩阵部件
    //创建按钮矩阵
    lv_obj_t* btnm = lv_btnmatrix_create(lv_scr_act());
    //定义按钮数组，最后一个元素必须为空
    static const char* map[] = {"btn1", "\n", "btn2", "btn3", ""};
    //设置按钮
    lv_btnmatrix_set_map(btnm, map);

//2、设置按钮相对宽度
    //参数2 0：btn1, 1:btn2, 2:btn3
    //参数3 btn3相对btn2的宽度为2倍
    lv_btnmatrix_set_btn_width(btnm, 1,2);
    lv_btnmatrix_set_btn_width(btnm, 2,1);

//3、获取按钮索引。文本
    /* 获取索引 */
lv_btnmatrix_get_selected_btn(btnm);	
/* 获取文本 */		
lv_btnmatrix_get_btn_text(btnm, id);

//4、设置、清楚按钮属性（不清楚看例子）
    lv_btnmatrix_set_btn_ctrl(btnm, 0, LV_BTNMATRIX_CTRL_CHECKABLE);
    //清楚上面设置的效果
    lv_btnmatrix_clear_btn_ctrl(btnm, 0, LV_BTNMATRIX_CTRL_CHECKABLE);
    //设置所有按钮
    lv_btnmatrix_set_btn_ctrl_all(btnm, LV_BTNMATRIX_CTRL_CHECKABLE);
    //改变颜色，注意map数组中内容要更改
    lv_btnmatrix_set_btn_ctrl(btnm, 0, LV_BTNMATRIX_CTRL_RECOLOR);
    static const char* map[] = {"#ff0000 btn1#", "\n", "btn2", "btn3", ""};

//5、设置单次选中属性
//需要先设置允许状态切换属性
//所有按钮中只能有一个按钮可被选中
lv_btnmatrix_set_one_checked(btnm, true);






/******************例子************ */
static void event_cb(lv_event_t* e)
{
    uint8_t id;
    lv_obj_t* target = lv_event_get_target(e);
    id = lv_btnmatrix_get_selected_btn(target);
    lv_label_set_text(input_label, lv_btnmatrix_get_btn_text(target, id));
}
void my_gui(void)
{
//1.创建USER标签
    label = lv_label_create(lv_scr_act());
    lv_label_set_text(label, "USER");
    lv_obj_set_style_text_font(label, &amp;lv_font_montserrat_20, LV_PART_MAIN);
    lv_obj_align(label, LV_ALIGN_LEFT_MID,150,-100);
//2.创建输入框
    input = lv_obj_create(lv_scr_act());
    lv_obj_set_size(input, 170,40);
    lv_obj_align_to(input, label, LV_ALIGN_OUT_BOTTOM_MID,0,20);
    //去除边框
    lv_obj_set_style_border_width(input, 0 ,0);
    //设置圆角
    lv_obj_set_style_radius(input, 20,0);
    //去除滚动条
    lv_obj_remove_style(input, NULL, LV_PART_SCROLLBAR);
//3.创建输入框标签
    input_label = lv_label_create(input);
    lv_obj_align_to(input_label, input,LV_ALIGN_TOP_MID,0, -10);
    lv_obj_set_size(input_label, 40, 40);
    lv_obj_set_style_text_font(input_label, &lv_font_montserrat_22, LV_PART_MAIN);
    lv_label_set_text(input_label, "");
//4.设置按钮矩阵
    btnm = lv_btnmatrix_create(lv_scr_act());
    //定义按钮数组，最后一个元素必须为空
    static const char* map[] = {"1", "2","3","\n",
                                "4", "5","6","\n",
                                "7", "8","9","\n",
                                "#", "0","%","",};
    //设置按钮
    lv_btnmatrix_set_map(btnm, map);
    lv_obj_align(btnm, LV_ALIGN_RIGHT_MID, -50, 0);
    lv_obj_set_size(btnm, 300, 300);
    lv_obj_set_style_text_font(btnm, &amp;lv_font_montserrat_24, LV_PART_ITEMS);
//    lv_btnmatrix_set_btn_ctrl_all(btnm, LV_BTNMATRIX_CTRL_CHECKABLE);
//    lv_btnmatrix_set_one_checked(btnm, true);
//5.按钮矩阵（优化界面）
    //去除边框
    lv_obj_set_style_border_width(btnm, 0,LV_PART_MAIN);
    //主体背景透明度
    lv_obj_set_style_bg_opa(btnm, 0, LV_PART_MAIN);
    //按钮背景透明度
    lv_obj_set_style_bg_opa(btnm, 0, LV_PART_ITEMS);
    //去除按钮阴影
    lv_obj_set_style_shadow_width(btnm, 0, LV_PART_ITEMS);
    lv_obj_add_event_cb(btnm, event_cb, LV_EVENT_PRESSED, NULL);
}